#include <xp/bas/str.h>
#include <xp/bas/stdio.h>

int xp_main ()
{
	xp_str_t str;

	if (xp_str_open(&str, 1) == XP_NULL) {
		xp_printf (XP_TEXT("cannot open a string\n"));
		return -1;
	}

	xp_printf (XP_TEXT("%ld\n"), 
		(long)xp_str_cat (&str, XP_TEXT("/0123456789")));
	xp_printf (XP_TEXT("%ld\n"), 
		(long)xp_str_cat (&str, XP_TEXT("itisnice")));
	xp_printf (XP_TEXT("%ld\n"), 
		(long)xp_str_cat (&str, XP_TEXT("it is nice/")));
	xp_printf (XP_TEXT("%ld\n"), 
		(long)xp_str_ccat (&str, XP_CHAR('Z')));
	xp_printf (XP_TEXT("%ld\n"), 
		(long)xp_str_catn (&str, XP_TEXT("BBB\0\0\0"), 6));
	xp_printf (XP_TEXT("%ld\n"), 
		(long)xp_str_ncat (&str, XP_TEXT("AAA\0\0\0"), 6));

	xp_printf (XP_TEXT("length = %ld, capacity = %ld\n"), 
		(long)xp_str_len(&str), (long)xp_str_capa(&str));
	xp_printf (XP_TEXT(" 123456789+123456789+123456789+123456789+123456789+\n"));
	xp_printf (XP_TEXT("[%s]\n"), xp_str_buf(&str));

	xp_str_close (&str);
	return 0;
}
